import * as React from "react";
import { Shell } from "@/components/shell";
import { Skeleton } from "@/components/ui/skeleton";
import { DataTableSkeleton } from "@/components/data-table/data-table-skeleton";
import { getDocumentClassCodeGroups } from "@/lib/docu-list-rule/document-class/service";
import { DocumentClassTable } from "@/lib/docu-list-rule/document-class/table/document-class-table";
import { InformationButton } from "@/components/information/information-button";
import { searchParamsDocumentClassCache } from "@/lib/docu-list-rule/document-class/validation";

interface IndexPageProps {
  searchParams: Promise<any>;
}

export default async function IndexPage(props: IndexPageProps) {
  const searchParams = await props.searchParams;

  const promises = Promise.all([
    getDocumentClassCodeGroups(
      searchParamsDocumentClassCache.parse(searchParams)
    ),
  ]);

  return (
    <Shell className="gap-2">
      <div className="flex items-center justify-between space-y-2">
        <div>
          <div className="flex items-center gap-2">
            <h2 className="text-2xl font-bold tracking-tight">Document Class 관리</h2>
            <InformationButton pagePath="evcp/docu-list-rule/document-class" />
          </div>
          {/* <p className="text-muted-foreground">
            Document Class를 관리합니다.
          </p> */}
        </div>
      </div>
      <React.Suspense fallback={<Skeleton className="h-7 w-52" />}></React.Suspense>
      <React.Suspense
        fallback={
          <DataTableSkeleton
            columnCount={4}
            searchableColumnCount={1}
            filterableColumnCount={1}
            cellWidths={["10rem", "20rem", "10rem", "8rem"]}
            shrinkZero
          />
        }
      >
        <DocumentClassTable promises={promises} />
      </React.Suspense>
    </Shell>
  );
} 